﻿<?php  
include("../imageThumb.class.php");
include("../function.php");

$target_path  = "upload/";//接收文件目录  
$target_path = $target_path . basename( $_FILES['pic']['name']);  
if(move_uploaded_file($_FILES['pic']['tmp_name'], $target_path)) {  
	
	//$_SESSION['login_mail'] == "qqq@qq.com";
	
	$time = time();
	$pictureup=$target_path;
	$name = "qqq@qq.com".$time.".jpg";
	$maxpicture="../up_image/big/".$name;
	$actual_name = iconv("UTF-8","gb2312",$maxpicture);//进行编码转换
	$minpicture="../up_image/small/".$name;
	$actual_name = iconv("UTF-8","gb2312",$minpicture);//进行编码转换
	$mediapicture="../up_image/media/".$name;
	$actual_name = iconv("UTF-8","gb2312",$mediapicture);//进行编码转换
	

	$resizeimage = new myThumbClass($pictureup,600,1,$maxpicture,-1,0);
	$resizeimage = new myThumbClass($pictureup,80,1,$minpicture,-1,0);
	$resizeimage = new myThumbClass($pictureup,300,1,$mediapicture,-1,0);
	//cutphoto($pictureup,$mediapicture,300,300);
	//$picture=$minpicture;
	
	imageStorage($name);

	
	copy($pictureup,"../up_image/original/".$name);
	unlink($pictureup);
	echo "上传成功";

}  else{  
   echo "There was an error uploading the file, please try again!" . $_FILES['pic']['error'];  
}  



//图片入库
function imageStorage($path){
	$city_lng=114.366938;
	$city_lat=30.523386;
	$address="湖北省武汉市洪山区";
	$name="";
	$remark="";
	$gallery=7;
  $user="qqq@qq.com";
  $time=date("Y-m-d H:i:s",time());
	mysql_query("INSERT INTO image (name,img_path,post_time,create_time,post_user,longitude,latitude,remark,address,gallery) VALUES ('$name','$path','$time','$time','$user','$city_lng','$city_lat','$remark','$address','$gallery')") or die(mysql_error());
}
    ?>  